import request from '@/utils/request'

export function getAppArray (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/getAppArray',
    method: 'post',
    data
  })
}

export function getAppInfo (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/getAppInfo',
    method: 'post',
    data
  })
}

export function getAppReArray (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/getAppReArray',
    method: 'post',
    data
  })
}

export function addAppData (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/addApp',
    method: 'post',
    data
  })
}

export function editAppData (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/editApp',
    method: 'post',
    data
  })
}

export function delAppData (params) {
  var data = fromData(params)
  return request({
    url: '/app_blue/del_app',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
